package cn.gson.springboot.model.pojos;

import javax.persistence.*;
import java.util.Collection;
import java.util.Objects;

@Entity
@Table(name = "warehouse_", schema = "crm")
public class Warehouse {
    private int warehouseId;
    private String warehouseName;
    private Collection<Inventory> inventoriesByWarehouseId;
    private Collection<Outbound> outboundsByWarehouseId;
    private Collection<Storage> storagesByWarehouseId;

    @Id
    @Column(name = "warehouse_id", nullable = false)
    public int getWarehouseId() {
        return warehouseId;
    }

    public void setWarehouseId(int warehouseId) {
        this.warehouseId = warehouseId;
    }

    @Basic
    @Column(name = "warehouse_name", nullable = true, length = 255)
    public String getWarehouseName() {
        return warehouseName;
    }

    public void setWarehouseName(String warehouseName) {
        this.warehouseName = warehouseName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Warehouse warehouse = (Warehouse) o;
        return warehouseId == warehouse.warehouseId &&
                Objects.equals(warehouseName, warehouse.warehouseName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(warehouseId, warehouseName);
    }

    @OneToMany(mappedBy = "warehouseByWarehouseId")
    public Collection<Inventory> getInventoriesByWarehouseId() {
        return inventoriesByWarehouseId;
    }

    public void setInventoriesByWarehouseId(Collection<Inventory> inventoriesByWarehouseId) {
        this.inventoriesByWarehouseId = inventoriesByWarehouseId;
    }

    @OneToMany(mappedBy = "warehouseByWarehouseId")
    public Collection<Outbound> getOutboundsByWarehouseId() {
        return outboundsByWarehouseId;
    }

    public void setOutboundsByWarehouseId(Collection<Outbound> outboundsByWarehouseId) {
        this.outboundsByWarehouseId = outboundsByWarehouseId;
    }

    @OneToMany(mappedBy = "warehouseByWarehouseId")
    public Collection<Storage> getStoragesByWarehouseId() {
        return storagesByWarehouseId;
    }

    public void setStoragesByWarehouseId(Collection<Storage> storagesByWarehouseId) {
        this.storagesByWarehouseId = storagesByWarehouseId;
    }
}
